#include<vector>
using namespace std;

class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix) {
        int m = matrix.size(), n = matrix[0].size();
        vector<vector<int>> tmp;
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++) {
                if (matrix[i][j] == 0)tmp.push_back({ i,j });
            }
        int count = tmp.size();
        for (int i = 0; i < count; i++) {
            int x = tmp[i][0], y = tmp[i][1];
            for (int j = 0; j < n; j++)matrix[x][j] = 0;
            for (int j = 0; j < m; j++)matrix[j][y] = 0;
        }
    }
};